package com.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.domain.pojo.HospitalizationCost;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface HospitalizationCostMapper extends BaseMapper<HospitalizationCost> {
    
    @Select("SELECT * FROM hospitalization_cost WHERE hId = #{hId} ORDER BY cDate DESC")
    List<HospitalizationCost> selectByHospitalization(Integer hId);
    
    @Select("SELECT SUM(cAmount) FROM hospitalization_cost WHERE hId = #{hId}")
    BigDecimal getTotalCostByHospitalization(Integer hId);
}
